// var ANIMA_BASE = "file:///C:/eclipse/workspace/HundredX/";
// var ANIMA_BASE = "file:///I:/desenvolvimento/eclipse-app/HundredX/";
var ANIMA_BASE = "http://fluidweb.sourceforge.net/hundredx/";

// var ANIMA_YUI = ANIMA_BASE + "lib/yui3.4.1/";
var ANIMA_YUI = "http://yui.yahooapis.com/3.4.1/build/";

var ANIMA_CONFIG =
{
   base: ANIMA_YUI,
   groups: {
      anima: {
         combine: false,  // there is not combo service (yet)
         base: ANIMA_BASE + "anima/",
         modules:  {
            "anima.component": {
               requires: ["node", "anima.component.jslocal"],
               path: "component/component.js"
            },
            "anima.component.base": {
               path: "component/base/componentbase.js"
            },
            "anima.component.view.base": {
               path: "component/view/base/widget-componentbase.js"
            },
            "anima.component.jslocal": {
               requires: ["anima.util", "anima.database.jslocal"],
               path: "component/jslocal/componentfactory.js"
            },
            "anima.composition": {
               requires: ["anima.component.jslocal"],
               path: "composition/composition.js"
            },
            "anima.util": {
               path: "util/util.js"
            },
            "anima.database.jslocal": {
               path: "database/jslocal/manager.js"
            },
         }
      },
      hundred: {
         combine: false,
         base: ANIMA_BASE + "hundred/",
         modules:  {
            "anima.hundred": {
               requires: ["anima.composition"],
               path: "hundred.js"
            }
         }
      },
      examples: {
         combine: false,  // there is not combo service (yet)
         base: ANIMA_BASE + "app/",
         modules:  {
            "app.lib.console": {
               path: "lib/console/console.js"
            },
            "app.lib.console_css": {
               path: "lib/console/console.css",
               type: "css"
            }
         }
      }
   }
};

var ANIMA = YUI(ANIMA_CONFIG);

var anima;

/* *******
 * Startup
 * *******
 */

(function animaStartup() {

ANIMA.anima = {

   base: ANIMA_BASE,
   
   yui:  ANIMA_YUI,
   
   registry: [],

   start: function(startFn) {
      ANIMA = ANIMA.use("anima.composition",
                        startFn);
   },
   
   hundred: function(startFn) {
      ANIMA.use("anima.hundred",
                function (A) {
                   A.anima.composition = A.anima.hundred.start();
                });
   },
   
   define: function(component) {
      if (component && component != null &&
          component.webid && component.webid != null &&
          component.creator && component.creator != null) {
         
         var componentDescriptor = {};
         
         // transfers all descriptor properties to register except the creator method
         for (property in component)
            if (property != "creator")
               componentDescriptor[property] = component[property];
            
         this.register(componentDescriptor);
         
         var componentConfig;
         if (component.superWebid)
            componentConfig = anima.database.jslocal.buildComponentConfig(
                  component.webid, component.superWebid);
         else
            componentConfig = anima.database.jslocal.buildComponentConfig(
                  component.webid);
         
         ANIMA.applyConfig(componentConfig);
 
         ANIMA.add(component.webid, component.creator);
      }
   },
   
   register: function(descriptor) {
      if (descriptor && descriptor != null &&
          descriptor.webid && descriptor.webid != null)
         this.register[descriptor.webid] = descriptor;
   },
   
   getDescriptor: function(webid) {
      return (this.register[webid]) ? this.register[webid] : null;
   },
   
   myLocation: function(A) {
	   
   }

};

anima = ANIMA.anima;

})();